<template>
  <div>
    <div style="margin-left: 20px;">
      <el-row v-if="contradictionRecord.img">
        <el-col :span="24">
          <label style="display: inline-block;">图片：</label>
          <ul>
            <li v-for="(item, index) in contradictionRecord.img" :key="index" style="display: inline-block; width: 150px; margin-left: 10px;">
              <!-- <span style="text-align: center;">{{ item.name }}</span> -->
              <el-image @click="enlarge(item.url)" :src="item.url" fit="contain">
                <div slot="placeholder" style="height: 100xp; width: 100px;">
                  <i style="font-size: 50px;" class="el-icon-loading" />
                </div>
              </el-image>
            </li>
          </ul>
        </el-col>
      </el-row>

      <el-row v-if="contradictionRecord.video">
        <el-col :span="24">
          <label style="display: inline-block;">视频：</label>
          <ul>
            <li v-for="(item, index) in contradictionRecord.video" :key="index" style="display: inline-block; width: 320px; margin-left: 10px;">
              <!-- <span style="text-align: center;">{{ item.name }}</span> -->
              <video width="320" height="240" :src="item.url" controls="controls">
                你的浏览器不支持
              </video>
            </li>
          </ul>
        </el-col>
      </el-row>

      <el-row v-if="contradictionRecord.audio">
        <el-col :span="24">
          <label>音频：</label>
          <ul>
            <li v-for="(item, index) in contradictionRecord.audio" :key="index" style="display: inline-block; width: 300px; margin-left: 10px;">
              <!-- <span style="text-align: center;">{{ item.name }}</span> -->
              <audio controls>
                <!-- <source src="horse.ogg" type="audio/ogg"> -->
                <source :src="item.url">
                您的浏览器不支持 audio 元素。
              </audio>
            </li>
          </ul>
        </el-col>
      </el-row>

      <el-row v-if="contradictionRecord.file">
        <el-col :span="24">
          <label>文件：</label>
          <ul>
            <li v-for="(item, index) in contradictionRecord.file" :key="index" style="display: inline-block; margin-left: 10px;">
              <a :href="item.url">{{ item.name }}<i class="el-icon-download" style="margin-left: 5px;" /></a>
            </li>
          </ul>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <label>描述：</label>
          <ul>
            <li style="display: inline-block; width: 100%;">
              <div v-html="contradictionRecord.description" />
            </li>
          </ul>
        </el-col>
      </el-row>

    </div>

    <div style="display: flex; align-items:center; justify-content:center; margin-top: 20px;">
      <el-button @click="cancel">关闭</el-button>
    </div>

    <el-dialog title="" append-to-body :visible.sync="showImage" top="10vh" width="75%">
      <div style="text-align: center;">
        <el-image :src="selectedImageUrl" fit="contain" />
      </div>
    </el-dialog>

  </div>
</template>

<script>
import request from '@/utils/request'
import qs from 'qs'
export default {
  components: {},
  props: ['selectedContradictionRecord'],
  data() {
    return {
      showImage: false,
      selectedImageUrl: '',
      contradictionRecord: {}
    }
  },
  created() {
    this.getContradictionRecordById();
  },
  mounted() {

  },
  methods: {
    getContradictionRecordById() {
      request({
        url: '/api/contradictionRecord/getContradictionRecordById',
        method: 'get',
        params: this.selectedContradictionRecord
      }).then((res) => {
        this.contradictionRecord = res.result;
        this.setcontradictionRecordPCRead();
      }).catch(() => {

      })
    },
    setcontradictionRecordPCRead() {
      request({
        url: '/api/contradictionRecord/setcontradictionRecordPCRead',
        method: 'post',
        data: qs.stringify({ contradictionId: this.contradictionRecord.contradictionId, institutionId: this.contradictionRecord.institutionId })
      }).then((res) => {

      }).catch(() => {

      })
    },
    enlarge(imgUrl) {
      this.selectedImageUrl = imgUrl;
      this.showImage = true;
    },
    cancel() {
      this.$emit('closeDialog');
    }
  }
};
</script>
<style scoped >

</style>
